<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:mo="https://gitee.com/aun/Timo">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
    <link rel="stylesheet" th:href="@{/lib/zTree_v3/css/zTreeStyle/zTreeStyle.css}" type="text/css">
    <link rel="stylesheet" th:href="@{/lib/layui-v2.3.0/css/layui.css}" type="text/css">
</head>
<body class="timo-layout-page">
<div class="layui-card" style="height: 321px;margin-bottom: 0px;">

    <div class="layui-card-body" >
        <form class="layui-form" action="">
        <div class="layui-form-item">
            <input type="hidden" th:value="${orderId}" id="orderId">
            <label class="layui-form-label">订单操作</label>
            <br/>
            <div class="layui-input-block">
                <th:block th:if="${tradeState != 3 && tradeState != 4 && tradeState != 5}">
                    <input type="radio"  name="guanli" value="0" title="确认收货" ><br/>
                </th:block>

                <input type="radio" name="guanli" value="1" title="删除订单" checked="checked">
            </div>
        </div>
        </form>
        <div class="lpull-left layui-form-pane timo-search-box" style="margin-top: 148px;">
            <button class="layui-btn"  onclick="queren()"><i class="fa fa-check-circle"></i> 确定</button>
            <button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
        </div>
    </div>
</div>
<script th:replace="/common/template :: script"></script>
<script type="text/javascript" th:src="@{/js/plugins/jquery-3.3.1.min.js}"></script>
<script type="text/javascript" th:src="@{/lib/zTree_v3/js/jquery.ztree.core.min.js}"></script>
<script type="text/javascript" th:src="@{/js/timoTree.js}"></script>
<script type="text/javascript">
    layui.use(['form','laydate'] ,function() {
        var laydate = layui.laydate,
            form  = layui.form;
        laydate.render({
            elem: '#time'
            ,type: 'datetime'
        });
    })
    function queren(){
        var orValue = $("input[name='guanli']:checked").val();
        var orderId = $("#orderId").val();
        if(orValue==0){
            layer.confirm('您要确认收货吗？', {
                btn: ['确定', '取消']

            }, function (index) {
                $.ajax({
                    type: "post",
                    url:"/mains/orders/updateOrder",
                    data:{"orderId":orderId,"orValue":orValue},
                    success:function (result) {
                        layer.alert(result, {offset: ['200px', '450px'], icon: 6});
                        setTimeout(function () {
                            parent.layer.closeAll();
                            parent.location.reload();
                        }, 1000)
                    }
                });
            })

        }else{
            layer.confirm('您要确认删除吗？', {
                btn: ['确定', '取消']

            }, function (index) {
                $.ajax({
                    type: "post",
                    url:"/mains/orders/updateOrder",
                    data:{"orderId":orderId,"orValue":orValue},
                    success:function (result) {
                        layer.alert(result, {offset: ['200px', '450px'], icon: 6});
                        setTimeout(function () {
                            parent.layer.closeAll();
                            parent.location.reload();
                        }, 1000)
                    }
                });
            })

        }

    }
</script>
</body>
</html>
